package com.zking.ssm.controller;

import com.zking.ssm.mapper.TeacherMapper;
import com.zking.ssm.model.Teacher;
import com.zking.ssm.service.ITeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
    private ITeacherService iTeacherService;
@RequestMapping("/addTeacher")
    public Map<String,Object> addTeacher(Teacher teacher){
    iTeacherService.insert(teacher);
    return  toJson("OK",null);

}
@RequestMapping("/queryTeacherAll")
public Map<String,Object> queryTeacherAll(Teacher teacher){
    List<Teacher> teachers = iTeacherService.queryTeacherAll(teacher);
    return toJson("OK",teachers);
}

public  Map<String,Object> toJson(String msg,Object data){
    Map<String,Object> json=new HashMap<>();
    json.put("success",true);
    json.put("msg",msg);
    json.put("data",data);
    return json;
}
}
